package cn.conow.pmo.dao;

import cn.conow.pmo.common.DICTPUB_PMO;
import cn.conow.pmo.entity.Person;
import cn.conow.pmo.params.AnnualPlanObjParam;
import cn.conow.system.common.DBHelper;
import cn.conow.system.common.Expression;
import cn.conow.system.dao.BaseDaoImpl;
import cn.conow.system.web.RequestContext;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * PersonDao层实现类
 * @author dapaer
 * @since v1.0.0
 */
@Repository("cn.conow.pmo.dao.PersonDaoImpl")
public class PersonDaoImpl extends BaseDaoImpl implements PersonDao{
	
	@Override
	public List<Person> queryByParams(Person person){
		DBHelper db = DBHelper.getInstances(Person.class);
		this.addExpressions(db, person);
		return db.queryObj();
	}
	
	@Override
	public List<Map> queryMapByParams(Person person){
		DBHelper db = DBHelper.getInstances(Person.class);
		this.addExpressions(db, person);
		return db.querySql();
	}
	
	@Override
	public List<Map> queryPageByParams(Person person){
		DBHelper db = DBHelper.getInstances(Person.class);
		this.addExpressions(db, person);
		return db.queryPageSql();
	}

	@Override
	public Map queryById(String id){
		DBHelper db = DBHelper.getInstances(Person.class);
		db.addCondition(Expression.eq("ID",person.getID())); 
		return db.queryPageSql();
	}


	private void addExpressions(DBHelper db, Person person){
		if(person == null){
			person = new Person();
		}
	
		db.setAutoFilterNullValue(true);
		
		 
		db.addCondition(Expression.eq("name",person.getname()));   
		db.addCondition(Expression.eq("age",person.getage()));   
		db.addCondition(Expression.eq("sex",person.getsex()));  
		
	}
	
	
}	


